﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PMC;

namespace PMCgui
{
    public enum Panel
    {
        Menu,
        Main,
    }

    public partial class Main : Form, ITransitionable
    {
        public Main(MenuStrip menuStrip, UserControl main)
        {
            InitializeComponent();
            Transition(menuStrip, Panel.Menu);
            Transition(main, Panel.Main);
        }

        private void Main_FormClosing(object sender, FormClosingEventArgs e)
        {
            Log.Instance.AddMessage("Closing. " + e.CloseReason);
        }

        public void Transition(Control c, Panel panel, bool updateLayout = false)
        {
            //Size = getSize(c.Size, panel == Panel.Main ? pnlMenustrip.Size + pnlMenustrip.Margin.Size : pnlMain.Size + c.Margin.Size);
            //if (!updateLayout) SuspendLayout(); else ResumeLayout();
            switch (panel)
            {
                case Panel.Menu:
                    pnlMenustrip.Controls.Clear();
                    pnlMenustrip.Controls.Add(c);
                    break;
                case Panel.Main:
                    pnlMain.Controls.Clear();
                    pnlMain.Controls.Add(c);
                    break;
            }
            
        }

        private Size getSize(Size first, Size second)
        {
            int borderWidth = SystemInformation.FrameBorderSize.Width;
            int borderHeight = SystemInformation.FrameBorderSize.Height;
            int width = (first.Width > second.Width) ? first.Width : second.Width + borderWidth + Margin.Horizontal;
            int height = first.Height + second.Height + borderHeight + Margin.Vertical;

            return new Size(width, height);
        }
    }
}
